package com.es.hotel.main;


import com.es.hotel.main.client.EsIndexClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;

//api对索引库的操作
public class EsIndexmain {
    private static final Logger log = LoggerFactory.getLogger(EsIndexmain.class);

    public static void main(String[] args) throws IOException {
        RestHighLevelClient client = EsIndexClient.client();
        //判断索引库是否存在
        if (EsIndexClient.existIndex(client, "hotel")) {
            log.error("索引库已经存在");
        }
        //创建索引库
        EsIndexClient.createIndex(client,"hotel");

        //删除索引库
        //EsIndexClient.deleteIndex(client,"hotel");
        client.close();
    }
}
